package genlog

import (
	"encoding/json"
	"log"
	"os"
	"time"

	"github.com/google/uuid"
)

type logx struct{
	Index int
	Uuid string
	Timestr string
	Time int
}

func Genlog(f string) {
	_f,err:=os.OpenFile(f,os.O_RDWR|os.O_APPEND,0644)
	if err!=nil{
		panic(err)
	}
	log.SetOutput(_f)
	index:=0
	
	for{
		index++
		a:=logx{
			index,
			uuid.NewString(),
			time.Now().Format("2006-01-02 15:04:05"),
			int(time.Now().Unix()),
		}
		txt,_:=json.Marshal(a)

		log.Println(string(txt))
		time.Sleep(time.Second)
	}
}